package fileReader.demo.reader;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;

public class PointDrawer extends LayerDrawer {

	protected double x;
	protected double y;
	protected String harborName;
	protected String typeSeaBed = "";
	protected String typeObstruct = "";
	protected String ntxstr = "";
	protected String typeLimit = "";
	protected double depth = 0;

	/**
	 * Draws this harbour to the screen
	 * @param g graphics
	 * @param zoom value
	 * @param xtrans x_translation
	 * @param ytrans y_translation
	 * @param layer layer in which data is stored 
	 */
	public void draw(Graphics g, double zoom, int xtrans, int ytrans, String layer) {
		g.setColor(Color.BLACK);
		double a=0;
		double b=0;
		
		double scalex = 1600.0/(MapLayer.getGlobalMax_x()-MapLayer.getGlobalMin_x());	//adapt this to your screen
		double scaley = 900.0/(MapLayer.getGlobalMin_y()- MapLayer.getGlobalMax_y());	//adapt this to your screen
		a = ((x - MapLayer.getGlobalMin_x())*scalex)*zoom+xtrans;
		b = ((y - MapLayer.getGlobalMin_y())*scaley +900.0)*zoom+ytrans;
		
		if(layer.contains("harbour")){
			g.setFont(new Font("Arial", Font.PLAIN, 12));
			g.drawString(harborName, (int)(a), (int)b);
		}else if(layer.contains("obstruct")){
			g.setColor(Color.DARK_GRAY);
			g.setFont(new Font("Arial", Font.PLAIN, 12));
			g.drawString(typeObstruct, (int) (a), (int)b);
		}else if(layer.contains("natseabed")){
			g.setColor(Color.RED);
			g.setFont(new Font("Arial", Font.PLAIN, 12));
			g.drawString(typeSeaBed, (int) (a), (int)b);
		}else if(layer.contains("text")){
			if(zoom>1.5)
			{
				g.setFont(new Font("Arial", Font.PLAIN, 12));
				if(ntxstr!=""){
					ntxstr.trim();
					g.drawString(ntxstr, (int)(a), (int)b);
				}
			}
		}else if(layer.contains("limitp")){
			g.setColor(Color.RED);
			g.setFont(new Font("Arial", Font.PLAIN, 12));
			g.drawString(typeLimit, (int)(a), (int)b);
		}else if(layer.contains("signsound")){
			if(zoom>1.5)
			{
				g.setFont(new Font("Arial", Font.PLAIN, 8));
				g.drawString(Double.toString(depth), (int)(a), (int)b);
			}
		}else if(layer.contains("rock")){		
			if(zoom>1.5)
			{
				g.setFont(new Font("Arial", Font.PLAIN, 12));
				if(this.depth>0){
					g.drawString("x", (int)(a), (int)b);
				}else if(this.depth==0){ 			
					g.drawString("-", (int)(a), (int)b);
				}else if(this.depth<0){ 			
					g.drawString("?", (int)(a), (int)b);
				}
			}
		}
	}

	/**
	 * This is a setter method for x.
	 * 
	 * @param x x value to set
	 */
	public void setX(double x) {
		this.x = x;
	}

	/**
	 * This is a setter method for y.
	 * 
	 * @param y y value to set
	 */
	public void setY(double y) {
		this.y = y;
	}

	public void setHarborName(String nameHarbor) {
		harborName=nameHarbor;		
	}

	/**
	 * @param typeSeaBed2 The typeSeaBed to set.
	 */
	public void setTypeSeaBed(String typeSeaBed) {
		this.typeSeaBed = typeSeaBed;
	}

	/**
	 * @param typeObstruct The typeObstruct to set.
	 */
	public void setTypeObstruct(String typeObstruct) {
		this.typeObstruct = typeObstruct;
	}

	/**
	 * @param ntxstr The ntxstr to set.
	 */
	public void setNtxstr(String ntxstr) {
		this.ntxstr = ntxstr;
	}

	/**
	 * @param typeLimit The typeLimit to set.
	 */
	public void setTypeLimit(String typeLimit) {
		this.typeLimit = typeLimit;
	}

	/**
	 * This is a setter method for depth.
	 * 
	 * @param depth depth value to set
	 */
	public void setDepth(double depth) {
		this.depth = depth;
	}

	/**
	 * This is a getter method for depth.
	 * 
	 * @return value of depth
	 */
	public double getDepth() {
		return depth;
	}

	public double getX() {
		return x;
	}

	public double getY() {
		return y;
	}

}
